# 原理：装饰类 只初始化一次 a = A()
def outer(a):  # a相当于A
    # 1.定义空字典 键是唯一的 类名当做键 对象引用作为值
    dic = {}
    def inner():
        if a not in dic:  # 判断
            # 2.实例化对象
            a1 = a()
            # 3.字典添加值
            dic[a] = a1
        return dic[a]  # 同一个对象对象的引用
    return inner


@outer
class A():
    pass
a1 = A()
print(a1)
a2 = A()
print(a2)